package 数列.斐波那契数列;

/**
 * TODO
 *
 * @className: fib
 * @description: TODO
 * @author: 等什么柠檬君
 * @date: 2022-04-27 18:20
 **/
public class fib {
    public static void main(String[] args) {
        System.out.println(fib(6));
    }

    public static int fib(int n) {
        int arr[] = new int[31];
        arr[0] = 0;
        arr[1] = 1;
        int sum = 0;
        for(int i = 2; i <= n; ++i){
            arr[i] = arr[i-1]+arr[i-2];
        }
        return arr[n];
    }
}
